<?
require("config.php");

$location_status .= " | Edit";

$show_backnav = "menu";

require($rela_path . "bin/country.php");

$menutype = 2;

if (NULL!=$action){

	$dir = $table . "/";

	if ($Picture1) myUpload($Picture1,$Picture1_name,$dir);
	if ($Picture2) myUpload($Picture2,$Picture2_name,$dir);
	if ($Picture3) myUpload($Picture3,$Picture3_name,$dir);
	if ($Picture4) myUpload($Picture4,$Picture4_name,$dir);


	if ($Picture1_name == null) $Picture1_name = $bk_Picture1;
	if ($Picture2_name == null) $Picture2_name = $bk_Picture2;
	if ($Picture3_name == null) $Picture3_name = $bk_Picture3;
	if ($Picture4_name == null) $Picture4_name = $bk_Picture4;


	if ($sm_Picture1) myUpload($sm_Picture1,"sm_" . $Picture1_name,$dir);
	if ($sm_Picture2) myUpload($sm_Picture2,"sm_" . $Picture2_name,$dir);
	if ($sm_Picture3) myUpload($sm_Picture3,"sm_" . $Picture3_name,$dir);
	if ($sm_Picture4) myUpload($sm_Picture4,"sm_" . $Picture4_name,$dir);


	if ($remove_1=="ture") $Picture1_name=NULL;
	if ($remove_2=="ture") $Picture2_name=NULL;
	if ($remove_3=="ture") $Picture3_name=NULL;
	if ($remove_4=="ture") $Picture4_name=NULL;


   $field = array(
	"code",
	"name",
	"date",
	"datedetails",
	"time",
	"venue",
	"country",
	"presented",
	"currency",
	"fee",
	"remark",
	"contact",
	"contact_tel",
	"contact_email",
	"status",
	"publish_date",
	"picture1",
	"picture2",
	"picture3",
	"picture4",
	"expiring_date",
	"currency1",
	"currency2",
	"currency3",
	"currency4",
	"currency5",
	"fee1",
	"fee2",
	"fee3",
	"fee4",
	"fee5",
	"description1",
	"description2",
	"description3",
	"description4",
	"description5",
	"order_index","showcase","course_link","trainer_link", "country2",
	);


   $content = array(
	$Code,
	$Name,
	"$Year-$Month-$Day",
	$DateDetails,
	$Time,
	$Venue,
	$Country,
	$Presented,
	$Currency,
	$Fee,
	$Remark,
	$Contact,
	$ContactTel,
	$ContactEmail,
	$Status,
	"$myYear-$myMonth-$myDay",
	$Picture1_name,
	$Picture2_name,
	$Picture3_name,
	$Picture4_name,
	"$Year1-$Month1-$Day1",
	$Currency1,
	$Currency2,
	$Currency3,
	$Currency4,
	$Currency5,
	$Fee1,
	$Fee2,
	$Fee3,
	$Fee4,
	$Fee5,
	$Description1,
	$Description2,
	$Description3,
	$Description4,
	$Description5,
	$Order_index,
	$showcase,$course_link, $trainer_link, $Country2,
	);

   $exp = "id='$id'";

   myUpdate($table,$field,$content,$exp);

   if ($Name!==$old_Name){

   $field = array(
	"schedule",
	);


   $content = array(
	$Name,
	);

   $exp = "schedule='$old_Name'";

   myUpdate("course_enrollment",$field,$content,$exp);
   myUpdate("course_sharing",$field,$content,$exp);

   }

   header("location:" . $rela_path . "share/msg.php?v=712&id=" . urlEncode($parent_id));

   exit();

}


$Query = "select 
	code,
	name,
	course,
	date,
	datedetails,
	time,
	venue,
	country,
	presented,
	currency,
	fee,
	remark,
	contact,
	contact_tel,
	contact_email,
	status,
	publish_date,
	picture1,
	picture2,
	picture3,
	picture4,
	expiring_date,
	currency1,
	currency2,
	currency3,
	currency4,
	currency5,
	fee1,
	fee2,
	fee3,
	fee4,
	fee5,
	description1,
	description2,
	description3,
	description4,
	description5,
	order_index, showcase, course_link, trainer_link, country2
from $table where id='$id' Limit 1";
$r = myQuery($Query);




	$Code=		$r[0][0];
	$Name=	$r[0][1];
	$Course=	$r[0][2];
	$Date=	$r[0][3];
	$DateDetails=	$r[0][4];
	$Time=	$r[0][5];
	$Venue=	$r[0][6];
	$Country=	$r[0][7];
	$Presented=	$r[0][8];
	$Currency=	$r[0][9];
	$Fee=	$r[0][10];
	$Remark=$r[0][11];
	$Contact=	$r[0][12];
	$ContactTel=	$r[0][13];
	$ContactEmail=	$r[0][14];
	$Status=	$r[0][15];
	$Publish_date=	$r[0][16];

	$Picture1= $r[0][17];
	$Picture2= $r[0][18];
	$Picture3= $r[0][19];
	$Picture4= $r[0][20];
	$Expiring_date = $r[0][21];

	$Currency1= $r[0][22];
	$Currency2= $r[0][23];
	$Currency3= $r[0][24];
	$Currency4= $r[0][25];
	$Currency5= $r[0][26];
	$Fee1= $r[0][27];
	$Fee2= $r[0][28];
	$Fee3= $r[0][29];
	$Fee4= $r[0][30];
	$Fee5= $r[0][31];
	$Description1= $r[0][32];
	$Description2= $r[0][33];
	$Description3= $r[0][34];
	$Description4= $r[0][35];
	$Description5= $r[0][36];
	$Order_index= $r[0][37];
$showcase=$r[0][38];
$course_link=$r[0][39];
$trainer_link=$r[0][40];
$Country2=$r[0][41];
require($rela_path . "inc/header.php");
require($rela_path . "bin/date.php");

?>

<form name="form1" enctype="multipart/form-data" method="post" action="">
<!--hidden filed-->
<input name="action" type="hidden" value="edit">
<input name="Code" type="hidden" value="<?print($Code)?>">
<input name="old_Name" type="hidden" value="<?print($Name)?>">
<input name="parent_id" type="hidden" value="<?print($parent_id)?>">


  <table width="95%" border="0" align="center">
    <tr> 
      <td align="right"> <input name="image" type="image" onclick="Redirect('menu.php?id=<?=$parent_id?>',1);return false;" src="../../images/bt_cancel.gif" width="78" height="23"> 
        <input name="image" type="image" src="../../images/bt_save.gif" width="76" height="22"  <?print($active)?>> 
      </td>
    </tr>
  </table>
  <table width="95%" border="0" align="center">
    <tr> 
      <td align="right">&nbsp; </td>
    </tr>
    <tr> 
      <td><table border="0">


          <tr> 
            <td class="tdheader">Schedule No. :</td>
            <td> <?print($Code)?> </td>
          </tr>

          <tr> 
            <td class="tdheader">Order : </td>
            <td><input type="text" class="text" name="Order_index" size="12" value="<?print($Order_index)?>"></td>
          </tr>
          <tr> 
            <td class="tdheader">Description : </td>
            <td><textarea class="text" name="Name" cols="40" rows="2"><?print(eregi_replace("&", "&amp;", $Name))?></textarea></td>
          </tr>
          <tr> 
            <td class="tdheader">Course :</td>
            <td> 
<?

if ($label){

	echo $label;
	echo "<input type=\"hidden\" name=\"Course\" value=\"$label\">";
	echo "<input type=\"hidden\" name=\"Course1\" value=\"" . eregi_replace("&", "&amp;", $label) . "\">";


}else{

$Query = "select name from course_basic";
$r = myQuery($Query);

$sourceData = array();

for ($i=0;$i<count($r);$i++){

	array_push($sourceData,$r[$i][0]);

	}


FFPSelectBox("Course",$Course,$sourceData,$sourceLabel);

}

?>            </td>
          </tr>
		  <SCRIPT LANGUAGE="JavaScript">
		  <!--
		  form1.type.value='<?print($type)?>';
		  //-->
		  </SCRIPT>
          <tr> 
            <td class="tdheader">Start on :</td>
            <td><?print(FFPdate($Date))?></td>
          </tr>
          <tr> 
            <td class="tdheader">Date Details :</td>
            <td><textarea class="text" name="DateDetails" cols="40" rows="4"><?print($DateDetails)?></textarea></td>
          </tr>
          <tr> 
            <td class="tdheader">Time :</td>
            <td><textarea class="text" name="Time" cols="40" rows="4"><?print($Time)?></textarea></td>
          </tr>
          <tr> 
            <td class="tdheader">Venue : </td>
            <td><textarea class="text" name="Venue" cols="40" rows="4"><?print($Venue)?></textarea></td>
          </tr>
          <tr>
            <td class="tdheader">Language :</td>
            <td><select name="Country2" class="select">
                <option value="dansk" <?php if ($Country2 == "dansk") { echo "Selected"; } ?>>dansk</option>
                <option value="engelsk" <?php if ($Country2 == "engelsk") { echo "Selected"; } ?>>engelsk</option>
                <option value="kantonesisk" <?php if ($Country2 == "kantonesisk") { echo "Selected"; } ?>>kantonesisk</option>
                <option value="Mandarin" <?php if ($Country2 == "Mandarin") { echo "Selected"; } ?>>Mandarin</option>
                <option value="dansk / engelsk" <?php if ($Country2 == "dansk / engelsk") { echo "Selected"; } ?>>dansk / engelsk</option>
                <option value="dansk / kantonesisk" <?php if ($Country2 == "dansk / kantonesisk") { echo "Selected"; } ?>>dansk / kantonesisk</option>
                <option value="dansk / Mandarin" <?php if ($Country2 == "dansk / Mandarin") { echo "Selected"; } ?>>dansk / Mandarin</option>
                <option value="kantonesisk / engelsk" <?php if ($Country2 == "kantonesisk / engelsk") { echo "Selected"; } ?>>kantonesisk / engelsk</option>
                <option value="engelsk / Mandarin" <?php if ($Country2 == "engelsk / Mandarin") { echo "Selected"; } ?>>engelsk / Mandarin</option>
                <option value="kantonesisk / Mandarin" <?php if ($Country2 == "kantonesisk / Mandarin") { echo "Selected"; } ?>>kantonesisk / Mandarin</option>
              </select>
            </td>
          </tr>
          <tr> 
            <td class="tdheader">Country :</td>
            <td><?print(FFPCountry($Country))?></td>
          </tr>
          <tr> 
            <td class="tdheader">Presented in : </td>
            <td><input class="select" name="Presented" type="text" size="40" value="<?print($Presented)?>"></td>
          </tr>
<!--
          <tr> 
            <td class="tdheader">Fee :</td>
            <td> 
              <?

$sourceData = array(
  "HKD",
  "USD",
  "GBP",
  "EURO",
  "DKK"
  );

FFPSelectBox("Currency",$Currency,$sourceData,$sourceLabel);

?>
              <input  class="text" name="Fee" type="text" size="12" value="<?echo $Fee?>"> </td>
          </tr>
-->
          <tr> 
            <td class="tdheader">Remark : </td>
            <td><input class="select" name="Remark" type="text" size="40" value="<?print($Remark)?>"></td>
          </tr>

          <tr> 
            <td class="tdheader">Contact Person</td>
            <td> 
              <?

$sourceData = array(
  "user 1",
  "user 2",
  "user 3",
  "user 4"
  );

//FFPSelectBox("Contact",$Contact,$sourceData,$sourceLabel);

?>
<input  class="text" name="Contact" type="text" size="40" value="<?echo $Contact?>">            </td>
          </tr>
          <tr> 
            <td class="tdheader">Contact E-mail:</td>
            <td><input class="select" name="ContactEmail" type="text" size="40" value="<?print($ContactEmail)?>"></td>
          </tr>
          <tr> 
            <td class="tdheader">Contact Tel:</td>
            <td><input class="select" name="ContactTel" type="text" size="40" value="<?print($ContactTel)?>"></td>
          </tr>












<input name="bk_Picture1" type="hidden" value="<?print($Picture1)?>">
<input name="bk_Picture2" type="hidden" value="<?print($Picture2)?>">
<input name="bk_Picture3" type="hidden" value="<?print($Picture3)?>">




          <tr> 
            <td class="tdheader">Picture 1</td>
            <td>
			
			<?removeImage($Picture1,"remove_1")?>
			
			<!--<br><b>(Normal Picture)</b><br>-->
			<?loadImage($Picture1,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture1" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture1,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture1" size="40">
			<br><br>            </td>
          </tr>



          <tr> 
            <td class="tdheader">Picture 2</td>
            <td>
			
			<?removeImage($Picture2,"remove_2")?>
			
			<!--<br><b>(Normal Picture)</b><br>-->
			<?loadImage($Picture2,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture2" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture2,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture2" size="40">
			<br><br>            </td>
          </tr>


          <tr> 
            <td class="tdheader">Picture 3</td>
            <td>
			
			<?removeImage($Picture3,"remove_3")?>
			
			<!--<br><b>(Normal Picture)</b><br>-->
			<?loadImage($Picture3,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture3" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture3,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture3" size="40">
			<br><br>            </td>
          </tr>



          <tr> 
            <td class="tdheader">Picture 4</td>
            <td>
			
			<?removeImage($Picture4,"remove_4")?>
			
			<!--<br><b>(Normal Picture)</b><br>-->
			<?loadImage($Picture4,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture4" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture4,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture4" size="40">
			<br><br>            </td>
          </tr>




<?for ($i=1;$i<6;$i++){
	
$v1 = "Currency$i";
$v2 = "Fee$i";
$v3 = "Description$i";

		if($i >= 4)
			$trDisplay = " style=\"display:none;\"";
		else
			$trDisplay = "";
	?>
          <tr <?=$trDisplay?>> 
            <td class="tdheader">Fee <?=$i?>:</td>
            <td>
<TABLE>
<TR>
	<TD>Currency:</TD>
	<TD><input type="text" name="<?="Currency$i"?>" size=5 class="text" value="<?=$$v1?>"></TD>
</TR>
<TR>
	<TD>Fee:</TD>
	<TD><input type="text" name="<?="Fee$i"?>" size=18 class="text" value="<?=$$v2?>"></TD>
</TR>
<TR>
	<TD>Description:</TD>
	<TD><textarea rows=5 cols=40 class=text name="<?="Description$i"?>"><?=$$v3?></textarea></TD>
</TR>
</TABLE>            </td>
          </tr>
<?}?>



          <tr>
            <td><strong>Course Name Link: </strong></td>
            <td><input name="course_link" type="text" class="text" id="course_link" value="<?=$course_link?>" size="40" /></td>
          </tr>
          <tr>
            <td><strong>Trainer Name Link: </strong></td>
            <td><input name="trainer_link" type="text" class="text" id="trainer_link" value="<?=$trainer_link?>" size="40" /></td>
          </tr>
          
          <tr>
            <td><strong>Sharing Showcase?</strong></td>
            <td><?
$sourceData = array(
1,
0,
);

$sourceLabel = array(
"Yes",
"No",

);

$boxName = "showcase";

FFPRadioBox($boxName,$showcase,$sourceData,$sourceLabel);


?>            </td>
          </tr>
          <tr> 
            <td valign="top" class="tdheader">Publish :</td>
            <td> 
			
              <?

$sourceData = array(
  "Yes",
  "No",
  );

$boxName="Status";

FFPCheckBox("Status",$Status,$sourceData,$sourceLabel);

?>            </td> 			  
          </tr>	
		  









          <tr> 
                  <td class="tdheader">Publishing Date :</td>
                  <td><?print(FFPtime($Publish_date))?></td>
                </tr>

          <tr> 
                  <td class="tdheader">Expiring Date :</td>
                  <td><?print(FFPdate1($Expiring_date))?></td>
                </tr>


        </table>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="95%" border="0" align="center">
    <tr> 
      <td align="right"> <input name="image2" type="image" onclick="Redirect('menu.php?id=<?=$parent_id?>',1);return false;" src="../../images/bt_cancel.gif" width="78" height="23"> 
        <input name="image2" type="image" src="../../images/bt_save.gif" width="76" height="22" <?print($active)?>> 
      </td>
    </tr>
  </table>
</form>
<?
require($rela_path . "inc/footer.php");
?>

